//counter的reducer 专门处理{number:0}
//把一个大型的状态划分为若干个小状态，然后由各自的reducer维护
//state 是状态树，可以是任意的结构
//action是个纯对象,类型和payload {type:'ADD',amount:2}
import * as types from '../types';

export default function (state = {number: 0}, action) {
    if (action === undefined) return state;
    switch (action.type) {
        case types.ADD:
            return {number: state.number + action.amount};
        case types.MINUS:
            return {number: state.number - action.amount};
        default:
            return state;
    }
}
